#include <halmach.h>
#include <halglobal.h>
#include <hallink.h>
#include <spinlock.h>
#include <list.h>

/*********************************************************************************
 * 
 * hal_mach_init - machine 结构体 初始化
 * 
 * DESCRIPTION
 */

void hal_mach_init (void)
    {
    mach_t_init (&osmachine);
    return;
    }

/*********************************************************************************
 * 
 * mach_t_init - machine 结构体 初始化
 * 
 * DESCRIPTION
 */

void mach_t_init 
    (
    mach_t * mach
    )
    {
    spinlock_init (&mach->lock);
    list_init (&mach->list);
    
    mach->krnlinramstart = KRNL_INRAM_START;
    mach->krnlinramend   = (addr_t) (&__end_kernel);
    mach->mmapdsc        = (mmapdsc_t *) (ALIGN ((uint_t) (&__end_kernel), 4096));   /* 内存管理数组起始存储地址 */
    mach->mmapdscnbr     = 0;

    /* 内存管理相关 */

    mach->phyaddrspcedsc = osmachineaddrspace;
    mach->phyaddrspcenbr = PLFM_ADDRSPACE_NBR;

    /* 中断管理相关 */

    mach->intsrcdsc      = osintsrcdsc;
    mach->intsrcdscnbr   = IRQ_SRC_MAX;

    return;
    }

/*********************************************************************************
 * 
 * mach_print - 打印 machine 结构体变量
 * 
 * DESCRIPTION
 */

void mach_print 
    (
    mach_t * mach
    )
    {
    kprintf ("mach.krnlinramstart: 0x%x\r\n", (uint_t) mach->krnlinramstart);
    kprintf ("mach.krnlinramend  : 0x%x\r\n", (uint_t) mach->krnlinramend);
    kprintf ("mach.mmapdsc       : 0x%x\r\n", (uint_t) mach->mmapdsc);
    kprintf ("mach.mmapdscnbr    : %d\r\n", (uint_t) mach->mmapdscnbr);
    kprintf ("mach.intsrcdsc     : 0x%x\r\n", (uint_t) mach->intsrcdsc);
    kprintf ("mach.intsrcdscnbr  : %d\r\n", (uint_t) mach->intsrcdscnbr);        
    return;
    }


